//项目入口文件
const express = require('express');
const app = express();
const path = require('path');
const homerouter = require('./routes/home');
const adminrouter = require('./routes/admin');
const bodyparser = require('body-parser');
const cookParser = require('cookie-parser');
// 设置获取静态资源
app.use(express.static(__dirname + '/public'));
// 设置模板
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// 设置处理post请求的数据
app.use(bodyparser.urlencoded({ extended: false }))
app.use(cookParser());
// 使用路由
app.use('/home', homerouter);
app.use('/admin', adminrouter);

app.listen(80, () => {
    console.log("服务器已经启动！");
})